package com.xxl.job.executor.structure;

import java.util.Stack;

public class TwoStackQueue{
    private final Stack<Integer> stackpush;
    private final Stack<Integer> stackpop;

    public TwoStackQueue(){
        stackpop = new Stack<>();
        stackpush = new Stack<>();
    }

    public void add(int o) {
        while(!stackpop.empty()){
            stackpush.push(stackpop.pop());
        }
        stackpush.push(o);
    }

    public void remove() {
        while(!stackpop.empty()){
            stackpush.push(stackpop.pop());
        }
        stackpush.pop();
    }

    public int peek() {
        while(!stackpush.empty()){
            stackpop.push(stackpush.pop());
        }
        return stackpop.peek();
    }
}
